<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/WEB-INF/view/console/common/css.html"){}	%>
 <% include("/WEB-INF/view/console/common/js.html"){} 	%>
     <link href="${ctxPath}/plugin/loading/loaders.css" type="text/css" rel="stylesheet" />
     <script src="${ctxPath}/plugin/loading/load.js"></script>
     <!-- 配置文件 -->
     <script type="text/javascript" src="${ctxPath}/plugin/utf8-jsp/ueditor.config.js"></script>
     <!-- 编辑器源码文件 -->
     <script type="text/javascript" src="${ctxPath}/plugin/utf8-jsp/ueditor.all.js"></script>
     <!-- 实例化编辑器 -->

 <title></title>
 </head>
 <body> <nav class="navbar navbar-default navbar-fixed-top site-navbar" >
  <div class="navbar-header">
 <a class="navbar-brand" href="#">表单</a>
 </div>
  </nav>
 <form name="boWebNews_form"  id="boWebNews_form" class="form-horizontal" style="margin-top: 60px;">
     <div class="form-group" >
         <label class="col-sm-2 control-label">标题</label>
         <div class="col-sm-6">
             <input  type="text"  name="title" id="title" class="form-control" check-type="required" value='${boWebNews.title!}' >
         </div>
     </div>

   <div class="form-group" >
 <label class="col-sm-2 control-label">是否发布</label>
 <div class="col-sm-6">
 <label><input checked='checked' auto_name='boWebNews_publish' type="radio"  name="publish" value="0"/>未发布</label>
 <label><input  auto_name='boWebNews_publish' type="radio"  name="publish" value="1"/>已发布</label>
  
 </div>
  </div>
 	<script type="text/javascript">
       $(function($){
       $('input[auto_name="boWebNews_publish"]').each(function(){
       if('${boWebNews.publish!}'==this.value){ 
             $(this).attr('checked','checked');
            }
           });
 	    });
 	</script> 
 <div class="form-group" >
 <label class="col-sm-2 control-label">作者</label>
 <div class="col-sm-6">
 <input  type="text"  name="author" id="author" class="form-control" check-type="required" value='${boWebNews.author!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">来源</label>
 <div class="col-sm-6">
 <input  type="text"  name="source" id="source" class="form-control" check-type="required" value='${boWebNews.source!}' >
 </div>
  </div>
     <input  type="hidden"  name="newsType" id="newsType" class="form-control" check-type="required" value='${boWebNews.newsType!}' >
 <div class="form-group" >
 <label class="col-sm-2 control-label">内容</label>
 <div class="col-sm-6">
     <!-- 加载编辑器的容器 -->
     <script id="content" name="content" type="text/plain">
         ${boWebNews.content!}
    </script>
     <script type="text/javascript">
         var ue = UE.getEditor('content');
     </script>
 </div>
  </div>
     <div class="form-group" >
         <label class="col-sm-2 control-label">简介</label>
         <div class="col-sm-6">
             <input  type="text"  name="intro" id="intro" class="form-control"   value='${boWebNews.intro!}' >
         </div>
     </div>
  <div class="form-group" >
 <label class="col-sm-2 control-label">封面</label>
 <div class="col-sm-3">
   <span class="btn btn-success fileinput-button">
        <i class="glyphicon glyphicon-plus"></i>
        <span>添加</span>
  <input type="file" id="cover_file" class="form-control" value='${boWebNews.cover!}' >
  <input type="hidden" id="cover"  name="cover"class="form-control" value='${boWebNews.cover!}' >
    </span>
  <div id="cover_progress" class="progress">
   <div class="progress-bar progress-bar-success"></div>
  </div>
  </div>
   	<div class="col-sm-4">
   	<img id="cover_file_show" src="${boWebNews.cover!}" style="width:100px;" alt="图片" class="img-rounded">
 </div>
 </div>

   <script type="text/javascript"> 
 $(function($){
  consoleUploadAliImg('cover','${ctxPath}');
 });
 </script> 
   <input type='hidden' name='id' id='id' value='${boWebNews.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 <div class="form-group" style="margin-bottom: 60px;"></div>
 </form>
 <script type="text/javascript">
 $(function($) {
    /*开启表单验证*/
 	$("#boWebNews_form").validation();
 });
 /*保存*/
 function saveZqForm(){
    if ($("#boWebNews_form").valid() == false) {
 	    return false;
    }
     new loadmodel().show();
    var formObject=new Object();
    formObject.publish=($('input[name="publish"]:checked').val()==''?null:$('input[name="publish"]:checked').val());
     formObject.intro=$('#intro').val()==''?null:$('#intro').val();
     formObject.title=$('#title').val()==''?null:$('#title').val();
 formObject.author=$('#author').val()==''?null:$('#author').val(); 
 formObject.source=$('#source').val()==''?null:$('#source').val(); 
 formObject.content= UE.getEditor('content').getContent();UE.getEditor('content').getContent()==''?null:UE.getEditor('content').getContent();
 formObject.cover=$('#cover').val()==''?null:$('#cover').val();
     formObject.newsType=$('#newsType').val()==''?null:$('#newsType').val();
 formObject.id=$('#id').val()==''?null:$('#id').val(); 
 
    var formObjectJson = JSON.stringify(formObject);
    $.post("${ctxPath}/console/bo_web_news/save",
     {
           formObjectJson :formObjectJson,
 	   table_name :'boWebNews',
 	   common_token :$("#common_token").val()
     }, function(data) {
        $.confirm({
              title: '提示',
              content: data.message,
              autoClose: 'cancelAction|3000',
              escapeKey: 'cancelAction',
              buttons: {
                  cancelAction: {
                      text: '确定',
                      action: function () {
                          parent.$("#boWebNews").bootstrapTable("refresh");
                          parent.art.dialog.get('id-dialog-boWebNews').close();
                      }
                  }
              }
 		});
            new loadmodel().hide();
     });
 }
 </script>
 <nav class="navbar navbar-default navbar-fixed-bottom site-navbar" >
 <div class="container" style="padding-top:10px;padding-bottom:10px;">
 <div class="nav navbar-nav navbar-right">
 <a href="#" class="btn btn-success"  onclick='saveZqForm()'>保存 </a>
  </div>
  </div>
  </nav>
 </body>
